<?php
	@include('include/common.inc.php');		
	$pro =$_POST["pro"];     // 区域
	$cate_id =$_POST["city"];     // 区域
	$typex =$_POST['type'];
	$price = $_POST['price'];
	$num = $_POST['num'];
	$address = $_POST['address'];

	if($city==''&$pro!='')
	{
		$sel4 = "select * from $TBL_HOU_CATE where parent_id = '$pro'";   //導航
		$res4 =$db->query($sel4);
		while($rows = $db->fetch_array($res4))
		{
			if($cate_id!='')
			{
				$cate_id=$rows['cate_id'].','.$cate_id;	
			}else{
				$cate_id=$rows['cate_id'];	
			}
		}
		$cate_id = " cate_id in ( $cate_id ) ";
	}else if($city!=''){
		$cate_id = "cate_id = $city";
	}else{
		$cate_id = "cate_id != 0";
	}  
	switch($price)
	{
		case '':
			$price_s = "";
		break;
		case '5000':
			$price_s = " and price=5000 ";
		break;
		case '8000':
			$price_s = " and price>5000 and price<=8000 ";
		break;
		case '12000':
			$price_s = " and price>8000 and price<=12000 ";
		break;
		case '15000':
			$price_s = " and price>12000 and price<=15000 ";
		break;
		case '20000':
			$price_s = " and price>15000 and price<=20000 ";
		break;
		case '30000':
			$price_s = " and price>20000 and price<=30000 ";
		break;
		case '50000':
			$price_s = " and price>30000 and price<=50000 ";
		break;
		case '50001':
			$price_s = " and price>50000";
		break;
	}    

	$search = " where address like '%$address%' and num like '%$num%' and (purpose like '%$typex%' or type like '%$typex%') and hou_type=2 and ".$cate_id.$price_s;

	$query = "select * from $TBL_HOUSE ".$search." and del=0 order by id asc";
	$cur_page = (int)$_GET["p"];   //获取当前页
	$url_param = preg_replace("/(p=[0-9]+)&/", "", $_SERVER['QUERY_STRING']);
	$pages = new Pager($query, $cur_page, 18, $url_param);
	$page_string = $pages -> getPageString();   
	$result = $pages -> getRsPerPage();
	$count = mysql_num_rows($result);
	$cou =0;
	while($rows = $db->fetch_array($result))
	{
		++$cou;		
		if($cou%2==0)
		{
			$color = "#ffffff";
		}else{
			$color = "#f0f0f0";
		}
		$rows['color']=$color;
		$row1[]=$rows;
	}

	$sel4 = "select * from $TBL_HOU_CATE where parent_id=0 order by cate_order asc";   //区域导航
	$res4 =$db->query($sel4);
	while($rows = $db->fetch_array($res4))
	{
		$row4[]=$rows;		
	}
	
	//群活动
	$seld = "select * from $TBL_DEAL order by id asc";
    $resd = mysql_query($seld);
	while($row = mysql_fetch_array($resd))
	{
		if($row[id]==1)
		{
			$imgsection = $row[img];//活动
			$imgshqb = $row[hou_id1];//活动
		}
		if($row[id]==3)
		{
			$imgzls = $row[img];//资料室
		}
		if($row[id]==4)
		{
			$text = $row[text];//跑马灯
		}
		if($row[id]==5)
		{
			$imgzz = $row[img];
			$admintext = $row[text];
		}	
	}


	$selaa = "select * from $TBL_OPTION where type=1 order by ord asc";//類型
	$resaa = mysql_query($selaa);	
	while($rowaa = mysql_fetch_array($resaa))
	{
       $typeaa = $typeaa ."<OPTION value=$rowaa[title]>".$rowaa[title]."</OPTION>";
	}
    $smarty->assign("text",$text);
	$smarty->assign("typeaa",$typeaa);
	$smarty->assign("row1",$row1);
	$smarty->assign("row4",$row4);	
	@include('number.php');//验证码
	$smarty->assign("page_string",$page_string);
	$smarty->assign("mem_id",$_SESSION['mem_id']);
	$smarty->assign("type",$_SESSION['type']);
	$smarty->display('rookery.html');
?>